package org.jetlinks.pro.koudai.web;


import io.swagger.v3.oas.annotations.tags.Tag;
import org.hswebframework.web.authorization.annotation.Resource;
import org.jetlinks.pro.koudai.Services.CourseTypeService;
import org.jetlinks.pro.koudai.Services.ResourceLibraryService;
import org.jetlinks.pro.koudai.entity.CourseTypeEntity;
import org.jetlinks.pro.koudai.entity.ResourceLibraryEntity;
import org.jetlinks.pro.koudai.tenant.KoudaiAssetType;
import org.jetlinks.pro.tenant.AssetType;
import org.jetlinks.pro.tenant.crud.TenantCorrelatesAccessCrudController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Nonnull;
import java.util.function.Function;

@RestController
@RequestMapping("/resource-library")
@Resource(id = "resource-library-manager", name = "课程资源管理")
@Tag(name = "课程资源管理")
public class ResourceLibraryController implements TenantCorrelatesAccessCrudController<ResourceLibraryEntity, String> {

    private final ResourceLibraryService resourceLibraryService;

    public ResourceLibraryController(ResourceLibraryService resourceLibraryService) {
        this.resourceLibraryService = resourceLibraryService;
    }


    @Override
    public ResourceLibraryService getService() {
        return resourceLibraryService;
    }

    @Nonnull
    @Override
    public AssetType getAssetType() {
        return KoudaiAssetType.resource;
    }

    @Nonnull
    @Override
    public Function<ResourceLibraryEntity, ?> getAssetIdMapper() {
        return ResourceLibraryEntity::getId;
    }

    @Nonnull
    @Override
    public String getAssetProperty() {
        return "resource";
    }
}
